﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class admin_news_modifyNews : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            int newsId = 0;
            try
            {
                newsId = Convert.ToInt32(Request["nid"]);
            }
            catch (Exception)
            {
                return;
            }
            idLabel.Text = Convert.ToString(newsId);
            News news = new DB().getNews(newsId);
            contentTextBox_cn.Text = news.Content_cn;
            contentTextBox_en.Text = news.Content_en;
            timeLabel.Text = news.PublishDate.ToString();
        }
    }
    protected void saveButton_Click(object sender, EventArgs e)
    {
        try
        {
            int id = Convert.ToInt32(idLabel.Text);
            DB db = new DB();
            db.modifyNews(id,contentTextBox_cn.Text,contentTextBox_en.Text);
        }
        catch (Exception)
        {
            Response.Redirect("../login.aspx");
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        contentTextBox_cn.Text = "";
        contentTextBox_en.Text = "";
    }
}
